import { HttpClient } from '@angular/common/http'
import { Injectable, ɵConsole } from '@angular/core'
import { Location } from '@angular/common'
import { catchError } from 'rxjs/operators'
import { Observable } from 'rxjs'
import { Subject } from 'rxjs'
import { JsStorage } from './jsStorage'

@Injectable()
export class UtilService {
  private localStorage: JsStorage
  private sessionStorage: JsStorage
  constructor(
    private location: Location,
    private http: HttpClient,
  ) {
    this.localStorage = new JsStorage(localStorage)
    this.sessionStorage = new JsStorage(sessionStorage)
  }
  // 清除 会话存储
  clearSessionStorage() {
    this.sessionStorage.clear()
  }
  // 会话存储
  setSessionStorage(key, value) {
    this.sessionStorage.setItem(key, value)
  }
  getSessionStorage(key) {
    return this.sessionStorage.getItem(key)
  }
  removeSessionStorage(key) {
    return this.sessionStorage.removeItem(key)
  }
  // 本地存储
  setLocalStorage(key, value) {
    this.localStorage.setItem(key, value)
  }
  getLocalStorage(key) {
    return this.localStorage.getItem(key)
  }
  removeLocalStorage(key) {
    return this.localStorage.removeItem(key)
  }
  removeLocalStoragelist(Tscope) {
    return this.localStorage.removeItemlist(Tscope)
  }
  clearLocalStorage() {
    return this.localStorage.clear()
  }

}
